package proxy.dynamicproxy.jdkproxy;

import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;

/**
 * FileName: JDKProxyTest
 * Author:   周壮
 * Date:     2020/3/9 14:25
 * Description:
 */
public class JDKProxyTest {
    public static void main(String[] args) {
        try {
            IPerson obj = new JdkMeipo().getInstance(new Zhangsan());
            obj.findLove();
            //通过反编译工具可以查看源代码
            byte[] bytes = ProxyGenerator.generateProxyClass("$Proxy0", new Class[]{IPerson.class});
            FileOutputStream os = new FileOutputStream("D://$Proxy0.class");
            os.write(bytes);
            os.close();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
